package com.ruoyi.warning.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.warning.domain.entity.Port;
import com.ruoyi.warning.domain.query.PortQuery;
import com.ruoyi.warning.domain.vo.PortVO;
import com.ruoyi.warning.mapper.PortsMapper;
import com.ruoyi.warning.service.IPortsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chenhc
 * @since 2025-03-26
 */
@Service
public class PortsServiceImpl extends ServiceImpl<PortsMapper, Port> implements IPortsService {
@Resource
private PortsMapper portsMapper;
    @Override
    public Object getAllPorts(PortQuery query) {
        Page<Port> page = PageHelper.startPage(query.getPageNum(),query.getPageSize());
        List<PortVO> list = portsMapper.getList(query);
        TableDataInfo tableDataInfo = new TableDataInfo(list, page.getTotal());
        return tableDataInfo;
    }

    @Override
    public Object getPortDetail(String id) {
        return this.getById(id);
    }

    @Override
    public Object getPortBandwidthUtilization(String id) {
        List<PortVO>list = portsMapper.getPortBandwidthUtilization(id);
        return list;
    }

    @Override
    public Object portStatusStatistics(String id) {
        Map<String, Object> map = portsMapper.portStatusStatistics(id);
        return map;
    }


}
